#include "window.h"
#include "widget_factory.h"

using namespace krryn::gui;

window::window(const with &a_Initializer)
: widget(create_widget_base<impl>()) {
	m_Pimpl = get_impl<impl>();
	m_Pimpl->make(a_Initializer);
	m_Pimpl->post_make(*this, a_Initializer.get_parent());
}

void *window::handle(){
	return m_Pimpl->handle();
}

window_initializer::window_initializer()
	: m_Title("krryn::window")
{
	width(640);
	height(480);

	top(100);
	left(100);
}

window_initializer::window_initializer(const properties &a_Props) : widget_initializer(a_Props) {
	if(!a_Props.has("width"))  width(640);
	if(!a_Props.has("height")) height(480);
	if(!a_Props.has("top"))    top(100);
	if(!a_Props.has("left"))   left(100);

	title(a_Props.get<std::string>("title", "krryn::window"));
}

window_initializer &window_initializer::title(const std::string &a_Title){
	m_Title = a_Title;
	return *this;
}

std::string window_initializer::get_title() const{
	return m_Title;
}

window* window_initializer::create(){
	return new window(*this);
}